$(function() {
//	下拉框兄弟下的节点
	$(document).on('click','.select_xl ul li',function(){
		$(this).parent().parent().parent().nextAll().children().children('span').text('请选择一级单位');
	})
	//	右下角
	$('.person_select1').hover(function() {
			$(this).children('ul').stop().slideDown();
			var jg_id = $('.jg_id').attr('jg_id')
			$.ajax({
				url: "?r=pub/lowerlevel",
				type: "POST",
				data: {
					'id': jg_id
				},
				error: function(error) {
					console.log(error);
				},
				success: function(msg) {
					var itemsArray = [];
					if(msg.data != '') {
						$(msg.data).each(function(index, item) {
								itemsArray.push(
									' <li class="item_select_li" jg_id="ID" ' + item.id + '">' + item.departname + '</li>'
								);
							}),
							$(".person_select1 #value").html(itemsArray.join(''));
					}
				},
				dataType: 'json',
			})
		},
		function() {
			$(this).children('ul').stop().slideUp()

		});
	$('.person_select2').hover(function() {
		
			$(this).children('ul').stop().slideDown();
			var bm_id = $('.bm_id').attr('bm_id');
			console.log(bm_id);
			$.ajax({
				url: "?r=pub/lowerlevel",
				type: "POST",
				data: {
					'id': bm_id
				},
				error: function(error) {
					console.log(error);
				},
				success: function(msg) {
					console.log(msg);
					var itemsArray = [];
					if(msg.data != '') {
						console.log(msg.data)
						$(msg.data).each(function(index, item) {
								itemsArray.push(
									' <li class="item_select_li" kt1_id="' + item.id + '">' + item.departname + '</li>'
								);
							}),
							$(".person_select2 #value").html(itemsArray.join(''));
					}
				},
				dataType: 'json',
			})
		},
		function() {
			$(this).children('ul').stop().slideUp()
		});

	//		课题组

	$(document).on('click', '.atlas_select_li1', function() {
		var kt1_id = $(this).attr('kt1_id');
		var val = $(this).text();
		$(this).parent().siblings('span').text(val);
		$('.ktz_id').attr('kt1_id', kt1_id);
		$('.kt_id').attr('kt1_id', kt1_id);

	});
	$('.person_select3').hover(function() {
			$(this).children('ul').stop().slideDown();
			var kt1_id = $(this).attr('kt1_id');
			console.log(kt1_id)
			$.ajax({
				url: "?r=pub/lowerlevel",
				type: "POST",
				data: {
					'id': kt1_id
				},
				error: function(error) {
					console.log(error);
				},
				success: function(msg) {
					//					console.log(msg);
					var itemsArray = [];
					if(msg.data != '') {
						//						console.log(msg.data)
						$(msg.data).each(function(index, item) {
								console.log(item)
								itemsArray.push(
									' <li class="item_select_li" kt1_id1="' + item.ID + '">' + item.departname + '</li>'
								);
							}),
							$(".person_select3 #value").html(itemsArray.join(''));
					}
				},
				dataType: 'json',
			})
		},
		function() {
			$(this).children('ul').stop().slideUp()

		});
	$(document).on('click', '.item_select_li', function() {
		var ry_id = $(this).attr('kt1_id1');
		var val = $(this).text();
		$(this).parent().siblings('span').text(val);
		$('.ryz_id').attr('kt1_id1', ry_id);
		$('.ry_id').attr('kt1_id1', ry_id);

	});
	$('.person_select4').hover(function() {
			$(this).children('ul').stop().slideDown();
			var ry_id = $(this).attr('kt1_id1');
			console.log(ry_id)
			$.ajax({
				url: "?r=budget/organization",
				type: "POST",
				data: {
					'org_id': ry_id,
					'user_id':'',
					'org_type':4
				},
				error: function(error) {
					console.log(error);
				},
				success: function(msg) {
//					console.log(msg);
					var itemsArray = [];
					if(msg.data != '') {
						console.log(msg.data)
						$(msg.data).each(function(index, item) {
								console.log(item);
								itemsArray.push(
									' <li class="item_select_li" kt10_id="' + item.ID + '">' + item.realname + '</li>'
								);
							}),
							$(".person_select4 #value").html(itemsArray.join(''));
					}
				},
				dataType: 'json',
			})
		},
		function() {
			$(this).children('ul').stop().slideUp()
		});

	//	下拉框课题
	$('.person_select5').hover(function() {
			$(this).children('ul').stop().slideDown();
			var org_code = $(this).attr('org_code');
			var org_type = $(this).attr('org_type');
			var org_id = $(this).attr('org_id');
			var user_id = $(this).attr('user_id');
			$.ajax({
				url: "?r=budget/organization",
				type: "POST",
				data: {
					'org_type': org_type,
					'org_code': org_code,
					'org_id': org_id,
					'user_id': user_id
				},
				error: function(error) {
					console.log(error);
				},
				success: function(msg) {
					var itemsArray = [];
					if(msg.data != '') {
						$(msg.data).each(function(index, item) {
								itemsArray.push(
									' <li class="item_select_li" item_id="' + item.id + '">' + item.project_no + '</li>'
								);
							}),
							$(".person_select5 #value").html(itemsArray.join(''));
					}
				},
				dataType: 'json',
			})
		},
		function() {
			$(this).children('ul').stop().slideUp()

		});
	// $('#value4>li').click(function(){

	//下拉框 选科目
	$('.person_select6').hover(function() {
			$(this).children('ul').stop().slideDown();
			var item_id = $(this).attr('item_id');
			var user_id = $(this).attr('user_id');
			$.ajax({
				url: "?r=budget/atlaselect",
				type: "POST",
				data: {
					'item_id': item_id
				},
				error: function(error) {
					console.log(error);
				},
				success: function(msg) {
					var itemsArray = [];
					if(msg.data != '') {
						$(msg.data).each(function(index6, item6) {
								itemsArray.push(
									' <li class="atlas_select_li" atlas_id="' + item6.id + '">' + item6.fee_name + '</li>'
								);

							}),
							$(".person_select6 #value").html(itemsArray.join(''));
					}

					console.log(item_id)
				},
				dataType: 'json',
			})
		},
		function() {
			$(this).children('ul').stop().slideUp()

		});

	$(document).on('click', '.iput_button', function() {
	
		var item_id = $('.item_id').attr('item_id');
		var user_id = $('.user_id').attr('user_id');
		var fee_id = $('.person_select6').attr('atlas_id');
		var tid = $('#ttid').attr('tid');
		var r_fee_name_arr = [];
		var r_budget_arr = [];
		var r_buy_arr = [];
		var fee_name_arr = [];
		var budget_arr = [];
		var buy_arr = [];
		var project_arr = [];
		$.ajax({
			url: "?r=budget/atlasfee",
			type: "post",
			data: {
				item_id: item_id,
				user_id: user_id,
				fee_id: fee_id,
				tid: tid
			},
			dataType: "json",
			error: function(error) {
				console.log(error);
			},
			success: function(msg) {
				console.log(msg)
				if(msg.code == 1) {
					if(msg.data != '') {
						$(msg.data).each(function(index, itemData) {
							$(itemData.left).each(function(ind, item) {
								//console.log(item);
								fee_name_arr.push(item.fee_name);
								budget_arr.push(item.budget_total);
								buy_arr.push(item.buy_total);
							})
						});
						//提出
						hideChart_one.setOption({
							xAxis: [{
								data: fee_name_arr
							}],
							// yAxis: {
							//     min: 0,
							//     max: 150,
							// },
							series: [{
								name: '预算总计',
								data: budget_arr
							}, {
								name: '已使用',
								data: buy_arr
							}]
						})
						fee_name_arr = [];
						budget_arr = [];
						buy_arr = [];
						//右边
//						$(msg.data).each(function(index, itemData) {
//							$(itemData.right).each(function(rind, rItem) {
//								r_fee_name_arr.push(rItem.project_name);
//								r_budget_arr.push(rItem.all_budget_total);
//								r_buy_arr.push(rItem.all_buy_total);
//								console.log(typeof(rItem.project_name));
//								projectItems[rind].name = rItem.project_name;
//								//								projectItems[rind].pgNum = 90 - rind*10;
//							})
//							hideChart_two.setOption({
//								xAxis: [{
//									data: r_fee_name_arr
//								}],
//								series: [{
//									name: '预算总计',
//									data: r_budget_arr
//								}, {
//									name: '已使用',
//									data: r_buy_arr
//								}]
//							})
//							for(var i = 0; i < projectItems.length; i++) {
//								// 创建放置进度圆环的div
//								var divElement = document.createElement('div');
//								divElement.setAttribute('id', 'pg' + i);
//								divElement.setAttribute('class', 'progress');
//								pgCon.appendChild(divElement);
//
//								// 使用echarts创建进度圆环
//								var echart = echarts.init(divElement);
//								makeChart(projectItems[i].pgNum, projectItems[i].name, judge_color(projectItems[i].pgNum));
//								echart.setOption(option);
//							}
//
//						})

					}
					$('.opacity_box').show()
			} else if(msg.code == 2) {
					$('.success').fadeIn()
				} else {
					alert("出错了");
				}

			}
		});

	});

	//关闭报销课题弹出框
	$(document).on('click', '.img1', function() {
		$('.opacity_box').fadeOut({
			duration: 200,
			complete: function() {}
		})
		// $('.img1').click(function() {

	})

	$('.success img').click(function() {
		$('.success').fadeOut()
	})

	//报销成功交互
	$('.success input').click(function() {
		var item_id = $('.item_id').attr('item_id');
		var tid = $('#ttid').attr('tid');
		var user_id = $('.user_id').attr('user_id');
		var fee_id = $('.person_select6').attr('atlas_id');
		var img = [];
		$.ajax({
			url: "?r=budget/atlasfee",
			type: "post",
			data: {
				tid: tid,
				user_id: user_id,
				fee_id: fee_id,
				item_id: item_id
			},
			dataType: "json",
			error: function(error) {
				console.log(error);
			},
			success: function(msg) {
				if(msg.data != '') {
					$('.img_one').attr('src','http:\/\/172.18.80.9:8081\/3\/ticket\/vat\/wangchunheng\/20180614\/20180614112304_kxQUYtMD.png');
					$('.right_img img').addClass('toggle_img');
					$('.right_img>p:nth-child(2) span:nth-child(2)').text('107000.00')
					$(msg.data).each(function(index, itemData) {
						console.log(msg.data)
						$(itemData.main).each(function(ind, item) {
							fee_name_arr.push(item.fee_name);
							budget_arr.push(item.budget_total);
							buy_arr.push(item.buy_total);
							all_budget = item.all_budget_total;
							all_buy = item.all_buy_total;
							console.log(itemData.image)
						})
						IQBar_temp.setOption({
							xAxis: [{
								data: fee_name_arr
							}],
							series: [{
								name: '预算总计',
								data: budget_arr
							}, {
								name: '已使用',
								data: buy_arr
							}]
						})
						fee_name_arr = [];
						budget_arr = [];
						buy_arr = [];
						//票
						var price = itemData.ticket.vatJine;
						// 加载饼状图数据
						IQpie_temp.setOption({
							series: [{
								name: '访问来源',
								data: [{
									value: all_buy,
									name: '未使用经费'
								}, {
									value: all_budget,
									name: '已使用经费'
								}],
							}]
						})
						fee_name_arr = []; // 课题名称数组
						budget_arr = []; // 课题预算数组
						buy_arr = []; // 课题已使用经费数组
						// $(itemData.main).each(function (ind, item) {
						//     fee_name_arr.push(item.fee_name);
						//     budget_arr.push(item.budget_total);
						//     buy_arr.push(item.buy_total);
						// })
							

					})
				}
			}
		})

		$('.success').fadeOut()
	})
	$(document).on('click', '#pg div', function() {
		$('.success').fadeIn()
		$('.opacity_box').hide()
	})

	// 全局变量
	var app = {};
	var option = null;
	var IQBar_temp, IQpie_temp;

	//数据交互
	//
	var all_budget = 0; // 已使用总经费
	var all_buy = 0; // 未使用总经费
	var fee_name_arr = []; // 课题名称数组
	var budget_arr = []; // 课题预算数组
	var buy_arr = []; // 课题已使用经费数组
	var item_info = ""; // 课题项目说明
	window.onload = function() {
		var item_id = $('.itemNo').attr('item_id');
		$.ajax({
			url: "?r=budget/itemfee",
			type: "post",
			data: {
				item_id: item_id
			},
			dataType: "json",
			error: function(error) {
				console.log(error);
			},
			success: function(msg) {
				var val = $(this).text();
				var atlas_id = $(this).attr('atlas_id');
				$(this).parent().siblings('span').text(val);
				$('.person_select6').attr('atlas_id', atlas_id);
				if(msg.data != '') {
					$(msg.data).each(function(index, itemData) {
						all_budget = itemData.all_budget_total;
						all_buy = itemData.all_buy_total;
						item_info = itemData.item_info;
						$('.right_img').find('p').eq(0).html(item_info);
						fee_name_arr.push(itemData.fee_name);
						budget_arr.push(itemData.budget_total);
						buy_arr.push(itemData.buy_total);

					})
					// 加载柱状图数据
					IQBar_temp.setOption({
						xAxis: [{
							data: fee_name_arr
						}],
						// yAxis: {
						//     min: 0,
						//     max: 150,
						// },
						series: [{
							name: '预算总计',
							data: budget_arr
						}, {
							name: '已使用',
							data: buy_arr
						}]
					})
					// 加载饼状图数据
					IQpie_temp.setOption({
						series: [{
							name: '访问来源',
							data: [{
								value: all_buy,
								name: '未使用经费'
							}, {
								value: all_budget,
								name: '已使用经费'
							}],
						}]
					})
					fee_name_arr = []; // 课题名称数组
					budget_arr = []; // 课题预算数组
					buy_arr = []; // 课题已使用经费数组
					// console.log(all_budget);
					// $(".person_select5 #value").html(itemsArray.join(''));
					// initData();
				}
			}
		})

	}
	$(document).on('click', '.item_but', function() {
		// createIQBar();
		// createIQPie();
		var item_id = $('.itemNo').attr('item_id');
		$.ajax({
			url: "?r=budget/itemfee",
			type: "post",
			data: {
				item_id: item_id
			},
			dataType: "json",
			error: function(error) {
				console.log(error);
			},
			success: function(msg) {
				if(msg.data != '') {
					$(msg.data).each(function(index, itemData) {
						all_budget = itemData.all_budget_total;
						all_buy = itemData.all_buy_total;
						item_info = itemData.item_info;
						$('.right_img').find('p').eq(0).html(item_info);
						fee_name_arr.push(itemData.fee_name);
						budget_arr.push(itemData.budget_total);
						buy_arr.push(itemData.buy_total);

					})
					// 加载柱状图数据
					IQBar_temp.setOption({
						xAxis: [{
							data: fee_name_arr
						}],
						// yAxis: {
						//     min: 0,
						//     max: 150,
						// },
						series: [{
							name: '预算总计',
							data: budget_arr
						}, {
							name: '已使用',
							data: buy_arr
						}]
					})
					// 加载饼状图数据
					IQpie_temp.setOption({
						series: [{
							name: '访问来源',
							data: [{
								value: all_buy,
								name: '未使用经费'
							}, {
								value: all_budget,
								name: '已使用经费'
							}],
						}]
					})
					fee_name_arr = []; // 课题名称数组
					budget_arr = []; // 课题预算数组
					buy_arr = []; // 课题已使用经费数组
					// console.log(all_budget);
					// $(".person_select5 #value").html(itemsArray.join(''));
					// initData();
				}
			}
		})
	})
	// 初始化数据
	// function initData(){
	//
	// }
	// initData();

	//课题柱状图开始
	// 课题查询图表初始化
	IQBar_temp = createIQBar();
	IQpie_temp = createIQPie();

	// 绘制课题查询柱状图
	function createIQBar() {
		// 基于准备好的dom，初始化echarts实例
		var IQBar = echarts.init(document.getElementById("container"));

		// 初始化图表
		app.title = '堆叠柱状图';
		var posList = [
			'left', 'right', 'top', 'bottom',
			'inside',
			'insideTop', 'insideLeft', 'insideRight', 'insideBottom',
			'insideTopLeft', 'insideTopRight', 'insideBottomLeft', 'insideBottomRight'
		];
		app.configParameters = {
			rotate: {
				min: -90,
				max: 90
			},
			align: {
				options: {
					left: 'left',
					center: 'center',
					right: 'right'
				}
			},
			verticalAlign: {
				options: {
					top: 'top',
					middle: 'middle',
					bottom: 'bottom'
				}
			},
			position: {
				options: echarts.util.reduce(posList, function(map, pos) {
					map[pos] = pos;
					return map;
				}, {})
			},
			distance: {
				min: 0,
				max: 100
			}
		};
		app.config = {
			rotate: 90,
			align: 'left',
			verticalAlign: 'middle',
			position: 'insideBottom',
			distance: 15,
			onChange: function() {
				var labelOption = {
					normal: {
						rotate: app.config.rotate,
						align: app.config.align,
						verticalAlign: app.config.verticalAlign,
						position: app.config.position,
						distance: app.config.distance
					}
				};
				IQBar.setOption({
					series: [{
						label: labelOption
					}, {
						label: labelOption
					}, {
						label: labelOption
					}, {
						label: labelOption
					}]
				});
			}
		};
		var labelOption = {
			normal: {
				show: true,
				position: app.config.position,
				distance: app.config.distance,
				align: app.config.align,
				verticalAlign: app.config.verticalAlign,
				rotate: app.config.rotate,
				fontSize: 16,
				rich: {
					name: {
						textBorderColor: '#fff'
					}
				}
			}
		};
		option = {
			tooltip: {
				trigger: 'axis',

				axisPointer: { // 坐标轴指示器，坐标轴触发有效
					type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
				}
			},

			color: ['#07a6fa', '#ff9a51', '#90EE90'],
			legend: {
				left: 'right',
				data: ['预算总计', '已使用']
			},
			axisLabel: {
				interval: 0,
				rotate: 40
			},
			grid: {
				left: '3%',
				right: '1%',
				bottom: '3%',
				containLabel: true
			},
			xAxis: [{
				type: 'category',
				"axisLabel": {
					interval: -10,
					rotate: -40,
				},
				data: []
			}],
			yAxis: [{
				type: 'value'
			}],
			series: [{
					name: '预算总计',
					type: 'bar',
					label: labelOption,
					data: []
				},
				{
					name: '已使用',
					type: 'bar',
					label: labelOption,
					barGap: '0%',
					data: []
				}
			]
		};
		if(option && typeof option === "object") {
			IQBar.setOption(option, true);
		};
		return IQBar;
	}
	// 绘制课题查询饼状图
	function createIQPie() {
		// 基于准备好的dom，初始化echarts实例
		var IQPie = echarts.init(document.getElementById("containerL"));
		option = {
			title: {
				text: '',
				subtext: '',
				x: 'center'
			},
			color: ['#6fdf7d', '#ff9445'],
			tooltip: {
				trigger: 'item',
				formatter: "{a} <br/>{b} : {c} ({d}%)"
			},
			legend: {
				itemWidth: 20,
				itemHeight: 10,
				itemGap: 10,
				icon: 'rect',
				left: 'right',
				data: ['未使用经费', '已使用经费']
			},
			series: [{
				name: '访问来源',
				type: 'pie',
				radius: '70%',
				center: ['50%', '50%'],
				data: [{
					value: 0,
					name: '未使用经费'
				}, {
					value: 0,
					name: '已使用经费'
				}],
				itemStyle: {
					emphasis: {
						shadowBlur: 10,
						shadowOffsetX: 0,
						shadowColor: 'rgba(0, 0, 0, 0.5)'
					},
					normal: {
						label: {
							show: true,
							formatter: '{b} : {c} ({d}%)', //百分比
							position: 'inner',
						},
						labelLine: {
							show: true
						}
					}
				}
			}]
		};
		if(option && typeof option === "object") {
			IQPie.setOption(option, true);
		}
		return IQPie;
	}

	//隐藏框柱状图
	var dom = document.getElementById("containerY");
	var hideChart_one = echarts.init(dom);
	var app = {};
	option = null;
	app.title = '堆叠柱状图';
	var posList = [
		'left', 'right', 'top', 'bottom',
		'inside',
		'insideTop', 'insideLeft', 'insideRight', 'insideBottom',
		'insideTopLeft', 'insideTopRight', 'insideBottomLeft', 'insideBottomRight'
	];

	app.configParameters = {
		rotate: {
			min: -90,
			max: 90
		},
		align: {
			options: {
				left: 'left',
				center: 'center',
				right: 'right'
			}
		},
		verticalAlign: {
			options: {
				top: 'top',
				middle: 'middle',
				bottom: 'bottom'
			}
		},
		position: {
			options: echarts.util.reduce(posList, function(map, pos) {
				map[pos] = pos;
				return map;
			}, {})
		},
		distance: {
			min: 0,
			max: 100
		}
	};
	app.config = {
		rotate: 90,
		align: 'left',
		verticalAlign: 'middle',
		position: 'insideBottom',
		distance: 15,
		onChange: function() {
			var labelOption = {
				normal: {
					rotate: app.config.rotate,
					align: app.config.align,
					verticalAlign: app.config.verticalAlign,
					position: app.config.position,
					distance: app.config.distance
				}
			};
			hideChart_one.setOption({
				series: [{
					label: labelOption
				}, {
					label: labelOption
				}, {
					label: labelOption
				}, {
					label: labelOption
				}]
			});
		}
	};

	var labelOption = {
		normal: {
			show: true,
			position: app.config.position,
			distance: app.config.distance,
			align: app.config.align,
			verticalAlign: app.config.verticalAlign,
			rotate: app.config.rotate,
			//					formatter: '{c}  {name|{a}}',
			fontSize: 16,
			rich: {
				name: {
					textBorderColor: '#fff'
				}
			}
		}
	};
	option = {
		tooltip: {
			trigger: 'axis',
			axisPointer: { // 坐标轴指示器，坐标轴触发有效
				type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
			}
		},
		legend: {
			left: 'right',
			data: ['预算总计', '已使用']
		},
		color: ['#07a9fa', '#ff8d3a'],
		grid: {
			left: '3%',
			right: '1%',
			bottom: '3%',
			containLabel: true
		},
		xAxis: [{
			type: 'category',
			"axisLabel": {
				interval: 0,
				rotate: -40
			},
			data: ['设备', '材料费', '测试化验', '燃料', '差旅费', '国际', '劳务费', '专家', '其他']
		}],
		yAxis: [{
			type: 'value'
		}],
		series: [{
				name: '预算总计',
				type: 'bar',
				label: labelOption,
				barGap: '0%',
				data: []
			},
			{
				name: '已使用',
				type: 'bar',
				stack: '广告',
				label: labelOption,
				barCateGoryGap: 20,
				data: []

				//			},
				//			{
				//				name: '等差',
				//				type: 'bar',
				//				label: labelOption,
				//				data: [200, 100, 120, 150, 179, 100, 170, 300],
				//						markLine: {
				//							lineStyle: {
				//								normal: {
				//									type: 'dashed'
				//								}
				//							},
				//							data: [
				//								[{
				//									type: 'min'
				//								}, {
				//									type: 'max'
				//								}]
				//							]
				//						}
			}
		]
	};;
	if(option && typeof option === "object") {
		hideChart_one.setOption(option, true);
	};

	//隐藏框柱状图
	var dom = document.getElementById("container_box_right");
	var hideChart_two = echarts.init(dom);
	var app = {};
	option = null;
	app.title = '堆叠柱状图';
	var posList = [
		'left', 'right', 'top', 'bottom',
		'inside',
		'insideTop', 'insideLeft', 'insideRight', 'insideBottom',
		'insideTopLeft', 'insideTopRight', 'insideBottomLeft', 'insideBottomRight'
	];

	app.configParameters = {
		rotate: {
			min: -90,
			max: 90
		},
		align: {
			options: {
				left: 'left',
				center: 'center',
				right: 'right'
			}
		},
		verticalAlign: {
			options: {
				top: 'top',
				middle: 'middle',
				bottom: 'bottom'
			}
		},
		position: {
			options: echarts.util.reduce(posList, function(map, pos) {
				map[pos] = pos;
				return map;
			}, {})
		},
		distance: {
			min: 0,
			max: 100
		}
	};
	app.config = {
		rotate: 90,
		align: 'left',
		verticalAlign: 'middle',
		position: 'insideBottom',
		distance: 15,
		onChange: function() {
			var labelOption = {
				normal: {
					rotate: app.config.rotate,
					align: app.config.align,
					verticalAlign: app.config.verticalAlign,
					position: app.config.position,
					distance: app.config.distance
				}
			};
			hideChart_two.setOption({
				series: [{
					label: labelOption
				}, {
					label: labelOption
				}, {
					label: labelOption
				}, {
					label: labelOption
				}]
			});
		}
	};

	var labelOption = {
		normal: {
			show: true,
			position: app.config.position,
			distance: app.config.distance,
			align: app.config.align,
			verticalAlign: app.config.verticalAlign,
			rotate: app.config.rotate,
			//					formatter: '{c}  {name|{a}}',
			fontSize: 16,
			rich: {
				name: {
					textBorderColor: '#fff'
				}
			}
		}
	};
	option = {
		tooltip: {
			trigger: 'axis',
			axisPointer: { // 坐标轴指示器，坐标轴触发有效
				type: 'shadow' // 默认为直线，可选为：'line' | 'shadow'
			}
		},
		color: ['#05baf9', '#00dcca', '#90EE90'],
		legend: {
			left: 'right',
			data: ['预算总计', '已使用']
		},
		color: ['#07a9fa', '#ff8d3a'],
		grid: {
			left: '3%',
			right: '1%',
			bottom: '3%',
			containLabel: true
		},
		xAxis: [{
			type: 'category',
			"axisLabel": {
				interval: 0,
				rotate: -40
			},
			data: []
		}],
		yAxis: [{
			type: 'value'
		}],
		series: [{
				name: '预算总计',
				type: 'bar',
				label: labelOption,
				barGap: '0%',
				data: []
			},
			{
				name: '已使用',
				type: 'bar',
				stack: '广告',
				label: labelOption,
				barCateGoryGap: 20,
				data: []
			}
		]
	};;
	if(option && typeof option === "object") {
		hideChart_two.setOption(option, true);
	};
	// 进度条默认颜色
	var color = '#409eff';
	// 课题对象数组
	//	var projectItems = [];

	var projectItems = [{
			pgNum: 90,
			name: "课题1"
		},
		{
			pgNum: 80,
			name: "课题2"
		}
	];
	var pgCon = document.getElementById("pg");

	function judge_color(num) {
		if(num < 70) {
			color = '#f56c6c';
		} else if(num < 80) {
			color = '#ff7f00';
		} else if(num < 90) {
			color = '#a996d4';
		} else if(num == 90) {
			color = '#67c23a';
		}

		return color;
	}
	// 绘制进度圆环
	function makeChart(pgNum, pName, color) {
		option = {
			tooltip: {
				trigger: 'item',
				formatter: "{a} <br/>{b}"
			},
			color: [color, "#DDD"],
			series: [{
				name: pName,
				type: 'pie',
				radius: ['50%', '70%'],
				avoidLabelOverlap: false,
				label: {
					normal: {
						show: true,
						textStyle: {
							fontSize: '15',
							fontWeight: 'bold'
						},
						position: 'center'
					}
				},
				data: [{
						value: pgNum,
						name: '\n推荐度' + pgNum + '%'
					},
					{
						value: 100 - pgNum,
						name: '\n不推荐度' + (100 - pgNum) + '%',
						label: {
							show: false
						}
					}
				]
			}]
		};
	}
});